//
//  HWpinglunfootView.m
//  HWanGame
//
//  Created by 陈道斌 on 2021/8/31.
//  Copyright © 2021 Chendaobin. All rights reserved.
//

#import "HWpinglunfootView.h"
#import "HWwenzipinglunViewController.h"
#import "HWpinglunxiangqingshituView.h"



@interface HWpinglunfootView()
//@property(strong,nonatomic) UIButton *dianzanBut;
//@property(strong,nonatomic) UIButton *pinglunBut;
//@property(strong,nonatomic) UILabel *shijianLabel;

@end


@implementation HWpinglunfootView

+ (instancetype)headFooterViewWithTableview:(UITableView *)tableview {
    
    HWpinglunfootView *view = [tableview dequeueReusableHeaderFooterViewWithIdentifier:NSStringFromClass([HWpinglunfootView class])];

      if (view == nil) {
          view = [[HWpinglunfootView alloc]initWithReuseIdentifier:NSStringFromClass([HWpinglunfootView class])];
      }
      view.backgroundColor = [UIColor yellowColor];
      return view;
    
}


- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    
    if(self = [super initWithReuseIdentifier:reuseIdentifier]){
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        
      //  UIButton
        
        
        self.dianzanBut = [UIButton  createNormalButtonWithFrame:CGRectMake(kScreenW -30-16-15, 10, 30+16, 16) Image:@"dianzanshuling" Title:@"2021" font:12 imageSize:CGSizeMake(16, 16)];
        [self.dianzanBut layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
        [self.dianzanBut setTitleColor:RGB(153, 153, 153) forState:UIControlStateNormal];
        [self.dianzanBut addTarget:self action:@selector(dianzanButTap) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.dianzanBut];
        
        self.pinglunBut = [UIButton  createNormalButtonWithFrame:CGRectMake(kScreenW -30-16-15-30-16-15, 10, 30+16, 16) Image:@"pinglunshujuico" Title:@"2021" font:12 imageSize:CGSizeMake(16, 15)];
        [self.pinglunBut layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
        self.pinglunBut.userInteractionEnabled = NO;
        [self.pinglunBut setTitleColor:RGB(153, 153, 153) forState:UIControlStateNormal];
        [self.contentView addSubview:self.pinglunBut];
        
        
        self.shijianLabel  = [[UILabel alloc]initWithFrame:CGRectMake( 60+10, 0, 200, 36)];
         self.shijianLabel.text = @"2021-8-10";
         self.shijianLabel.font = [UIFont systemFontOfSize:12];
         self.shijianLabel.textColor = RGB(153, 153, 153);
       //  self.nameNiChengLabel.backgroundColor = [UIColor redColor];
         self.shijianLabel.textAlignment =  NSTextAlignmentLeft;
     //    self.jianjienLabel.layer.borderWidth = 1;
     //    self.jianjienLabel.layer.borderColor = RGB(38, 154, 255).CGColor;
     //    self.jianjienLabel.layer.cornerRadius = 3;
     //    self.jianjienLabel.layer.masksToBounds = YES;
        [self.contentView addSubview:self.shijianLabel];
        [self.pinglunBut addTarget:self action:@selector(pingluntap) forControlEvents: UIControlEventTouchUpInside];
        
        
        
        self.fengeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 35, kScreenW, 1)];
        self.fengeImageView.image = [UIImage imageNamed:@"fenggexiangico"];
        
        [self.contentView addSubview: self.fengeImageView];
        
        
        self.fenggexiangView = [[UIView alloc] initWithFrame:CGRectMake(60, 35, kScreenW -60-10, 0.5)];
        self.fenggexiangView.backgroundColor = RGB(235, 235, 235);
        self.fenggexiangView.hidden = YES;
        [self.contentView addSubview: self.fenggexiangView];
        
        
        
        
        
        UITapGestureRecognizer *tap =  [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(footTap)];
        [self.contentView addGestureRecognizer:tap];
        
        UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];//初始化一个长按手势
        [longPress setMinimumPressDuration:1];//设置按多久之后触发事件
        [self.contentView addGestureRecognizer:longPress];//把长按手势添加给按钮
         
        
        
    }
    
    
    return  self;
    
}

-(void)setModel:(HWpinglunFrame *)model {
    _model = model ;
    HWpinglunModel *data=   model.datamodel;
    
    self.shijianLabel.text = data.time;
    
    [self.pinglunBut  setTitle:data.num forState:UIControlStateNormal];
    [self.dianzanBut  setTitle:data.zan forState:UIControlStateNormal];
    [self.pinglunBut layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
    [self.dianzanBut layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
    
    if ([data.is_zan isEqualToString:@"1"]) {
        
        [self.dianzanBut setImage:[UIImage imageNamed:@"HWzanzan"] forState:UIControlStateNormal];
         
    } else {
        
        [self.dianzanBut setImage:[UIImage imageNamed:@"dianzanshuling"] forState:UIControlStateNormal];
        
    }
    
    
}


- (void)pingluntap {
    

//    HWpinglunxiangqingshituView *pinglun = [[HWpinglunxiangqingshituView alloc]init];
//    pinglun.idStr = self.model.datamodel.id;
//    [[HWViewUtils getCurrentVC].navigationController pushViewController:pinglun animated:YES];
    
//    HWpinglunModel *data=   self.model.datamodel;
//    HWwenzipinglunViewController *pinglun = [[HWwenzipinglunViewController alloc]init];
//    pinglun.pid = data.id;
//    pinglun.gameIDStr = data.gid;
//    [[HWViewUtils getCurrentVC].navigationController pushViewController:pinglun animated:YES];
//
//
    
    
}


- (void)dianzanButTap {
    
    
    if ([self.delegate respondsToSelector:@selector(HWpinglunfootView:sectionInt:)]) {
        [self.delegate  HWpinglunfootView:self.model sectionInt:self.section];
    }
    
    
}



- (void)footTap {
    
    
    
    if ([self.delegate respondsToSelector:@selector(HWpinglunfootView:)]) {
        [self.delegate HWpinglunfootView:self.model];
        
        
    }
    
}


-(void)longPressAction:(UILongPressGestureRecognizer*)sender{
 //    UIGestureRecognizerStatePossible,按钮state的各种枚举值
 //    UIGestureRecognizerStateBegan,
 //    UIGestureRecognizerStateChanged,
 //    UIGestureRecognizerStateEnded,
 //    UIGestureRecognizerStateCancelled,
 //    UIGestureRecognizerStateFailed,
 //    UIGestureRecognizerStateRecognized = UIGestureRecognizerStateEnded
    if (sender.state == UIGestureRecognizerStateBegan) {
         //  myBtn.backgroundColor = [UIColor greenColor];//当状态为Began时，触发事件（修改btn的背景色）
    } else if (sender.state == UIGestureRecognizerStateEnded) {
        
        NSLog(@"diiodioiodiho");
        
        
        
    }
    
    
    


}

 



@end
